

*Program to get all of a states data in one quarter;
*Revise program on 2024 04 09;

libname input "/OEUS/FEDS/";
libname output "/OEUS/users/FEDSusers/QCEW/data/QuartData";
options  errors=1;
%let date=20140202;

%include "/OEUS/users/FEDSusers/QCEW/Programs/naics2dig.sas";

%let state =  ak al ar az ca co ct dc de ga hi ia id il
  in ks la md me mn mo mt nd ne nj nm nv oh ok or sc sd tn tx ut va vt wa wv;

%let statenum=39;

%macro mac(Qrt=,Yr=);

%let qrtyr=&Yr&Qrt;
proc delete data=output.ldb&qrtyr;

%do counter=1 %to &statenum;
	%let st=%scan(&state,&counter);

	proc append base=ldb&qrtyr data=input.&st&qrtyr
	 (keep=ldb_num state_fips tot_wage m1_empl m2_empl m3_empl yr_qtr naics succ_break_consol_flag pred_break_consol_flag own_code);
	
	data output.ldb&qrtyr; set ldb&qrtyr;
	
              if own_code~=5 then delete;
              
              %naics2dig;
              

	run;
	

%end;
%mend mac;



%macro allquarters(YrBeg=,YrEnd=);


%do z=&YrBeg %to &YrEnd;
	%do j=1 %to 4;
	   
	    %mac(Qrt=&j,Yr=&z);

	   %end;
%end;
%mend;


%allquarters(YrBeg=1992,YrEnd=2016);


